package com.hw.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;

@WebServlet(name = "SSServlet",urlPatterns = "/shoop")
public class SSServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       request.setCharacterEncoding("utf-8");
        ArrayList<String > shoplist=new ArrayList<>(Arrays.asList(request.getParameterValues("shop")));
        HttpSession session=request.getSession();
        session.setAttribute("shop",shoplist);
        RequestDispatcher dispatcher= request.getRequestDispatcher("/session.html");
        dispatcher.forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
